package com.mybatis.learning.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

import com.mybatis.learning.mapper.provider.XgkApiCourseAreaProvider;
import com.mybatis.learning.model.XgkApiCourseArea;

public interface XgkApiCourseAreaMapper {

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table xgk_api_course_area
     * @mbg.generated
     */
    int insert(XgkApiCourseArea record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table xgk_api_course_area
     * @mbg.generated
     */
    List<XgkApiCourseArea> selectAll();
    
    @Results(id="resultMap",value={
        @Result(property="id",column="id",id=true),
        @Result(property="provCode",column="prov_code"),
        @Result(property="courseCode",column="course_code"),
        @Result(property="courseName",column="course_name"),
        @Result(property="sycType",column="syc_type")
    })
    @Select({"select id,prov_code,course_code,course_name,syc_type,create_time ",
        "from xgk_api_course_area where id=#{id}"})
    XgkApiCourseArea selectById(String id);
    
    @ResultMap("resultMap")
    @Select({"select id,prov_code,course_code,course_name,syc_type ",
    "from xgk_api_course_area where prov_code=#{provCode}"})
    List<XgkApiCourseArea> selectByProvCode(String provCode);
    
    @Insert({
        "insert into xgk_api_course_area (id,prov_code,course_code,course_name,syc_type,create_time)",
        " values ",
        "(#{id},#{provCode},#{courseCode},#{courseName},#{sycType},#{createTime})"
    })
    int insertXgkApiCourseArea(XgkApiCourseArea entity);
    
    @Insert({
        "insert into xgk_api_course_area (id,prov_code,course_code,course_name,syc_type,create_time)",
        " values ",
        "(#{id},#{provCode},#{courseCode},#{courseName},#{sycType},#{createTime})"
    })
    @SelectKey(statement="select REPLACE(UUID(),'-','')",
    keyProperty="id",
    resultType=String.class,
    before=true)
    int insertXgkApiCourseArea2(XgkApiCourseArea entity);
    
    @Update({"update xgk_api_course_area set prov_code=#{provCode} where id=#{id}"})
    int updateById(XgkApiCourseArea entity);
    
    @Delete("delete from xgk_api_course_area where id=#{id}")
    int deleteById(String id);
    
    @SelectProvider(type=XgkApiCourseAreaProvider.class,method="selectById")
    XgkApiCourseArea selectById2(String id);
}